﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BHXH.Core.Domain;
using BHXH.Core.IService;
using FX.Core;
using Infragistics.Win.UltraWinGrid;

namespace BHXH.Frm.FrmUserControl
{
    public partial class Thubhxh_DanhSach : UserControl
    {
        private readonly IhosoService _hosoSrv;
        public Thubhxh_DanhSach()
        {
            InitializeComponent();
            _hosoSrv = IoC.Resolve<IhosoService>();
            LoadDataGridview();
        }

        public DataTable GetAll_DanhSachThu()
        {
            IList<hoso> a = _hosoSrv.layTatCaHoSo_ThuBHXH_103();
            DataTable table = new DataTable();
            table.Columns.Add("STT", typeof(string));
            table.Columns.Add("Loại giấy tờ, biểu mẫu", typeof(string));
            table.Columns.Add("Chọn", typeof(bool));
            table.Columns.Add("Số lượng", typeof(int));
            table.Columns.Add("LoaiHienThi", typeof(string));
            foreach (var item in a)
            {
                table.Rows.Add(item.STT, item.Ten, item.TrangThaiChon, item.SoLuong, item.LoaiHienThi);
            }
            return table;
        }

        public void LoadDataGridview()
        {
            uG_DanhSachHS_103.DataSource = GetAll_DanhSachThu();
            uG_DanhSachHS_103.DisplayLayout.Override.ActiveCellAppearance.Reset();
            uG_DanhSachHS_103.DisplayLayout.Override.ActiveRowAppearance.Reset();
            uG_DanhSachHS_103.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;
            this.uG_DanhSachHS_103.DisplayLayout.Bands[0].Columns[0].Width = 20;
            this.uG_DanhSachHS_103.DisplayLayout.Bands[0].Columns[1].Width = 200;
            this.uG_DanhSachHS_103.DisplayLayout.Bands[0].Columns[2].Width = 50;
            this.uG_DanhSachHS_103.DisplayLayout.Bands[0].Columns[3].Width = 50;

            this.uG_DanhSachHS_103.DisplayLayout.Bands[0].Columns[0].CellActivation = Activation.NoEdit;
            this.uG_DanhSachHS_103.DisplayLayout.Bands[0].Columns[1].CellActivation = Activation.NoEdit;
            this.uG_DanhSachHS_103.Rows[11].Cells[2].Activation = Activation.NoEdit;
            this.uG_DanhSachHS_103.Rows[16].Cells[2].Activation = Activation.NoEdit;
            this.uG_DanhSachHS_103.Rows[20].Cells[2].Activation = Activation.NoEdit;
            this.uG_DanhSachHS_103.Rows[22].Cells[2].Activation = Activation.NoEdit;
            this.uG_DanhSachHS_103.DisplayLayout.Bands[0].Columns["LoaiHienThi"].Hidden = true;
            for (int i = 0; i < uG_DanhSachHS_103.Rows.Count; i++)
            {
                if (this.uG_DanhSachHS_103.Rows[i].Cells[4].Value.ToString() == "0")
                {
                    uG_DanhSachHS_103.Rows[i].Cells[2].Hidden = true;
                    uG_DanhSachHS_103.Rows[i].Cells[3].Hidden = true;
                }
            }
        }
    }
}
